package com.emmmya.ocs;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.junit.jupiter.api.Test;

import java.util.List;

public class testPlay1 {
    @Test
    public void test1() throws DocumentException {
        String str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n" +
                "    <soap:Body>\n" +
                "        <MainJobLogResponse xmlns=\"WWW.SUNWODA.COM\">\n" +
                "            <MainJobLogResult>\n" +
                "                true\n" +
                "            </MainJobLogResult>\n" +
                "        </MainJobLogResponse>\n" +
                "    </soap:Body>\n" +
                "</soap:Envelope>";
        Document document = DocumentHelper.parseText(str);
        Element rootElement = document.getRootElement();
        System.out.println(rootElement.getName());
        List<Element> elements =
                rootElement.elements();
        for (int i = 0; i < elements.size(); i++) {
            System.out.println(elements.get(i).getName());
            List<Element> elements1 = elements.get(i).elements();
            for (int i1 = 0; i1 < elements1.size(); i1++) {

                System.out.println(elements1.get(i1).getName());
            }
        }
        Element element = rootElement.element("Body");
        System.out.println(element);
        String sendMesresult = element.element("MainJobLogResponse").element("MainJobLogResult").getTextTrim();
        System.out.println(sendMesresult);

    }
}
